home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 4 / Meeting Pearls Vol. IV (1996)(GTI - Schatztruhe)[!].iso / Pearls / midi / misc / Midi2TeX / src / tp_misc.pas < prev   
Pascal/Delphi Source File  |  1992-07-23  |  5KB  |  177 lines

  1. UNIT TP_Misc;
  2.  
  3. INTERFACE
  4.  
  5. uses TP_decl,
  6.      Printer,DOS;
  7.  
  8.  
  9. Function  I2S(Num : Integer): String;
  10. Function  SI2S(Num : ShortInt): String;
  11. Function  B2S(Num : Byte): String;
  12. Function  LI2S(Num : LongInt): String;
  13. Function  W2S(Num : Word): String;
  14. Function  TimeDiff(time2,time1:MeasureTime):LongInt;
  15. Function  EqualTime(time2,time1:MeasureTime):Boolean;
  16. Procedure SetTime(VAR time:MeasureTime; M,P : WORD);
  17. Procedure AddTime(time2,time1:MeasureTime;VAR time3 : MeasureTime);
  18. Procedure DisplayLicense;
  19. Function  FileExists (Filename : STRING) : BOOLEAN;
  20. Function Power(TheNumber,TheExp:Byte):word;
  21.  
  22. IMPLEMENTATION
  23.  
  24. (**********************************************)
  25.    Function Power(TheNumber,TheExp:Byte):word;
  26. (**********************************************)
  27. VAR tmp : word;
  28. BEGIN
  29. Tmp:=1;
  30. While TheExp>0 DO
  31.     Begin
  32.     Tmp:=Tmp*TheNumber;
  33.     DEC(TheExp); 
  34.     End;
  35. Power:=Tmp;
  36. End;  (* power *) 
  37.  
  38.  
  39. (********************************************************)
  40.     Procedure WriteDebugInfo(Instring : String);
  41. (********************************************************)
  42. Begin
  43. If debug then
  44.     case debugout of 
  45.         SCREEN      : WriteLn(InString);
  46.         DEBFILE     : WriteLn(DebugFile,Instring);
  47.         PRINT       : WriteLn(Lst,Instring);
  48.     End;    
  49. End;    
  50.  
  51. (********************************************************)
  52.         Function I2S(Num : Integer): String;
  53. (********************************************************)
  54. VAR Res : String[25];
  55. Begin
  56. Str(Num,Res);
  57. I2S:=REs;
  58. End;        
  59.  
  60. (********************************************************)
  61.         Function SI2S(Num : ShortInt): String;
  62. (********************************************************)
  63. VAR Res : String[25];
  64. Begin
  65. Str(Num,Res);
  66. SI2S:=Res;
  67. End;
  68.  
  69. (********************************************************)
  70.         Function B2S(Num : Byte): String;
  71. (********************************************************)
  72. VAR Res : String[25];
  73. Begin
  74. Str(Num,Res);
  75. B2S:=REs;
  76. End;        
  77.  
  78. (********************************************************)
  79.         Function LI2S(Num : LongInt): String;
  80. (********************************************************)
  81. VAR Res : String[25];
  82. Begin
  83. Str(Num,Res);
  84. LI2S:=REs;
  85. End;        
  86.  
  87.      
  88. (********************************************************)
  89.         Function W2S(Num : Word): String;
  90. (********************************************************)
  91. VAR Res : String[25];
  92. Begin
  93. Str(Num,Res);
  94. W2S:=REs;
  95. End;        
  96.  
  97. (********************************************************)
  98.     Function  TimeDiff(time2,time1:MeasureTime):LongInt;
  99. (********************************************************)
  100. VAR dt : Longint;
  101. Begin
  102. dt:=(time2.Measure-time1.Measure)*PieceContr.TicksPerMeasure;
  103. dt:=dt+time2.MPart-time1.MPart;
  104. TimeDiff:=dt;
  105. End;
  106.  
  107. (********************************************************)
  108.     Function  EqualTime(time2,time1:MeasureTime):Boolean;
  109. (********************************************************)
  110. Begin
  111. EqualTime:=TRUE;
  112. If time2.Measure<>time1.Measure Then EqualTime:=FALSE;
  113. If time2.Mpart<>time1.Mpart Then EqualTime:=FALSE;
  114. End;
  115.  
  116.  
  117. (*********************************************************************)
  118.     Procedure AddTime(time2,time1:MeasureTime;VAR time3 : MeasureTime);
  119. (*********************************************************************)
  120. VAR M : Longint;
  121. Begin
  122. M:=PieceContr.TicksPerMeasure*(time1.Measure+time2.Measure)+time1.MPart+time2.MPart;
  123. time3.Measure:=M div PieceContr.TicksPerMeasure;
  124. time3.MPart:=M mod PieceContr.TicksPerMeasure;
  125. End;
  126.  
  127. (*********************************************************************)
  128.     Procedure SetTime(VAR time:MeasureTime; M,P : WORD);
  129. (*********************************************************************)
  130. Begin
  131. time.Measure:=M ;
  132. time.MPart:=P;
  133. End;
  134.  
  135. (********************************************************)
  136.     Procedure DisplayLicense;
  137. (********************************************************)
  138. VAR
  139.     f : File;
  140.     T : Longint;
  141.     DT : DateTime; (* defined in DOS unit *)
  142. Begin
  143. WriteLn('********************************************************');
  144. Write('*  Midi2TeX translator ',version);
  145. {$IFDEF PC}
  146.       Write(' of ');
  147.       Assign(f,ParamStr(0));
  148.       GetFTime(f,T);
  149.       UnPackTime(T,DT);
  150.       With DT Do WriteLn(Day,'-',Month,'-',Year,',',Hour,':',Min);
  151. {$ENDIF}
  152. {$IFDEF ST} WriteLn('                   *'); {$ENDIF}
  153. WriteLn('*           author:  H.J.P. Kuykens                    *');
  154. WriteLn('********************************************************');
  155. End;
  156.  
  157. (**************************************************)
  158.  FUNCTION FileExists (Filename : STRING) : BOOLEAN;
  159. (**************************************************)
  160.      VAR
  161.         f : FILE;
  162.      BEGIN
  163.         {$I-}
  164. {$IFDEF PC}        
  165.         ASSIGN (f, FileName);
  166.         RESET (f);     
  167. {$ENDIF}        
  168. {$IFDEF ST}
  169.         RESET (f,FileName);     
  170. {$ENDIF}        
  171.         CLOSE (f);
  172.         {$I+}
  173.         FileExists := (IORESULT = 0) AND (FileName <> '');
  174.         END;  { FileExists}
  175.  
  176. Begin
  177. End.